home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
jovept2.arc
/
MAKEUTIL.C
< prev
next >
Wrap
Text File
|
1985-05-30
|
3KB
|
159 lines
/* file makeutil.c */
/* utilities for "make" for ms-dos */
/* K. Mitchum 7/84 */
#include <stdio.h>
#include "bdos.h"
#define ERROR -1
/* bdos utilities */
find_first(name)
unsigned char *name;
{
struct regval srv;
struct segs rv;
char *kludge;
kludge = name;
while(*kludge) {
if(isspace(*kludge)) *kludge = '/0';
else kludge++;
}
segread(&rv);
srv.ds = rv.sds;
srv.es = rv.ses;
srv.cx = 0;
srv.ax = (O_FIND_FIRST);
srv.dx = name;
sysint21(&srv,&srv);
return(!(srv.ax & 0xff00));
}
struct dta {
char dosuse[21];
char attr_found;
long dttime;
unsigned long dta_size;
char dta_name[13];
char dta_fill[90];
};
struct dta dta;
struct param_block pblock;
struct segs segs;
/* the following function must be called prior to using the */
/* file date/time function */
set_dta()
{
bdos(O_SET_DTA,&dta);
return;
}
/* version for compatibility with make. */
long dateof()
{
static long datetime;
datetime = dta.dttime;
return(datetime);
}
execl(cmd,arglist)
char *cmd, *arglist;
{
char buf[200];
strcpy(buf,cmd);
strcat(buf," ");
strcat(buf,arglist);
fprintf(stdout,"\n%s\n",buf);
if(strcmp(cmd,"cc")==0) {
if(do_cc(buf,arglist)) return ERROR;
}
else {
if(system(buf)) return ERROR;
return(bdos(O_RET_CODE,0));
}
}
do_cc(buf,arglist)
char *buf, *arglist;
{
int i;
for(i = 1; i < 5; i++) {
sprintf(buf,"C:\\SYS\\CC%d.EXE",i);
if(execf(buf,arglist)) return ERROR;
if(bdos(O_RET_CODE,0)) return ERROR;
if(i==1) stripflag(arglist);
}
return(0);
}
stripflag(arglist)
char *arglist;
{
while(*arglist) {
if(*arglist == '-') *arglist = '\0';
else arglist++;
}
}
execf(prog,arg)
unsigned char *prog, *arg;
{
struct {unsigned int ax,bx,cx,dx,si,di,ds,es;}srv;
struct {
int env_seg;
char *line_off,*line_seg;
char *fcb1_off,*fcb1_seg;
char *fcb2_off,*fcb2_seg;
} ctrl;
unsigned char cline[128],*ep;
int status=-1;
ctrl.fcb1 = " ";
ctrl.fcb2 = " ";
if(strlen(prog)>123) return ERROR;
srv.ax=0x4800;
srv.bx=0xfff0; /* look for a lot of memory */
if((sysint21(&srv,&srv)&1) && srv.bx<(64*17)) return ERROR;
cline[0]=strlen(arg);
strcpy(cline+1,arg);
segread(&srv.si);
ctrl.env_seg=0;
ctrl.line_off=cline;
ctrl.line_seg=srv.ds;
ep = prog;
return(status=loadexec(ep,srv.ds,&ctrl,srv.ds,0));
}